<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
    <hr/>
    <news></news>
  </div>
  <template id="tpl1">
    <div>
      <h1>home组件</h1>
      <button @click="change">按钮</button>
      {{ isShow?'喜欢你':'讨厌你' }}
    </div>
  </template>
  <template id="tpl2">
    <div>
      <h1>news组件</h1>
      {{ isShow?'你真好看':'你真懒' }}
    </div>
  </template>
  <script src="./vue.js"></script>
  <script>
    // 定义一个混入
    const mixin = {
      data(){
        return {
          isShow:true
        }
      },
      methods:{
        change(){
          this.isShow = !this.isShow
        }
      }
    }
    const Home = {
      template:"#tpl1",
      data(){
        return {
          isShow:false
        }
      },
      mixins:[mixin]
    }

    Vue.component('Home',Home)
    const News = {
      template:"#tpl2",
      mixins: [mixin]
    }

    Vue.component('News',News)
    const vm = new Vue({
      el:"#app"
    })
  </script>
</body>
</html>
